package org.rain.bee.controller;

import java.security.Principal;
import java.util.HashMap;
import java.util.Map;

import org.rain.bee.dao.TbSysUserMapper;
import org.rain.bee.domain.TbSysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("dashboard")
public class BeeController {
	
	@Value("${aa}")
	private String aa;
	
	@Autowired
	private TbSysUserMapper tbSysUserMapper;

	@RequestMapping("message")
	public Map<String, Object> dashboard() {
		
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("aa", aa);
		
		TbSysUser user = new TbSysUser();
		
		user.setUserName("ssss");
		user.setUserPassword("张三");
		
		tbSysUserMapper.insert(user);
		
		return map;
	}

	@RequestMapping("user")
	@PreAuthorize("hasAnyRole('admin', 'user')")
	public String user(Principal user) {
		return "a";
	}

	@RequestMapping("dashboard/login")
	public String dashboard2() {
		return "redirect:/#/";
	}

}
